struct Solution {}

fn main() {}

impl Solution {
    pub fn count_subarrays(nums: Vec<i32>) -> i32 {
        let mut end = 2 as usize;
        let len = nums.len();
        (end..len).filter(|idx| Self::check(&nums[idx - 2 ..idx + 1])).count() as i32
    }

    fn check(nums: &[i32]) -> bool {
        let a = nums[0];
        let b = nums[1];
        let c = nums[2];
        if b == 0 && (a + c) == 0 {
            return true;
        }
        (a + c) != 0 && b % (a + c) == 0 && b / (a + c) == 2
    }
}